#include <bits/stdc++.h>
using namespace std;
#define int long long
int gcd(int a,int b)
{
	return b==0?a:gcd(b, a%b);
}
void solve()
{
	int n;
	cin>>n;
	int a,b,c,d;
	int ans=0;
	vector<vector<short>> v(10001,vector<short>(10001));
	for(int i=1;i<=n;i++)
	{
		cin>>a>>b>>c>>d;
		if(a==c)
		{
			if(b>d)swap(b,d);
			for(int i=b;i<=d;i++)if(v[a][i]++==1)ans++;
			continue;
		}
		if(b==d)
		{
			if(a>c)swap(a,c);
			for(int i=a;i<=c;i++)if(v[i][b]++==1)ans++;
			continue;
		}
		int div=gcd((d-b),(c-a));
		if(div<0)div*=-1;
		int y=(d-b)/div;
		int z=(c-a)/div;
		for(int i=a,j=b;i!=c+z;i+=z,j+=y)if(v[i][j]++==1)ans++;
	}
	cout<<ans<<endl;
}
signed main()
{
	//ios::sync_with_stdio(false);
	//cin.tie(nullptr);
	int T=1;
	//cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
}